{% macro render_notification(notification) %}
    {% import _self as render %}
    {% if  notification.subject ==  'follow_user'%}
        {{ render.render_follow_user(notification) }}
    {% elseif notification.subject ==  'reply_topic' %}
        {{ render.render_reply_topic(notification) }}
    {% elseif notification.subject ==  'comment_post' %}
        {{ render.render_comment_post(notification) }}
    {% elseif notification.subject ==  'mention_user_in_topic' %}
        {{ render.render_at_user_in_topic(notification) }}
    {% elseif notification.subject ==  'mention_user_in_post' %}
        {{ render.render_at_user_in_post(notification) }}
    {% elseif notification.subject ==  'follow_category' %}
        {{ render.render_follow_category(notification) }}
    {% endif %}
{% endmacro %}

{# 渲染好友关注 #}
{% macro render_follow_user(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 关注了你
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
    </div>
{% endmacro %}

{# 渲染回复话题 #}
{% macro render_reply_topic(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 回复了你的话题
            <a href="{{ path('topic_view', {id: notification.topic.id}) }}">{{ notification.topic.title }}</a>
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染在话题@ #}
{% macro render_at_user_in_topic(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 在话题
            <a href="{{ path('topic_view', {id: notification.topic.id}) }}">{{ notification.topic.title }}</a>提到了你
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染在文章艾特 #}
{% macro render_at_user_in_post(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 在文章
            <a href="{{ path('post_view', {id: notification.post.id}) }}">{{ notification.post.title }}</a>提到了你
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染评论文章 #}
{% macro render_comment_post(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 评论了你的文章
            <a href="{{ path('post_view', {id: notification.post.id}) }}">{{ notification.post.title }}</a>
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
        <div class="body markdown-body">{{ notification.message|raw }}</div>
    </div>
{% endmacro %}

{# 渲染订阅专栏通知 #}
{% macro render_follow_category(notification) %}
    <div class="media-body">
        <div class="heading">
            <a class="username" href="{{ path('user_view', {username: notification.fromUser.username}) }}">{{ notification.fromUser.username }}</a> 订阅了你的专栏
            <a href="{{ path('category_view', {slug: notification.category.slug}) }}">{{ notification.category.name }}</a>
            <div class="time meta">{{ notification.createdAt|time_diff }}</div>
        </div>
    </div>
{% endmacro %}